#coding:utf-8
import pygtk
pygtk.require('2.0')
import gtk
from winit import winit

class MyWindow(winit):
    def __init__(self, title, width, height):
        winit.__init__(self, title, width, height)

        self.fixed = gtk.Fixed()
        self.label = gtk.Label('MessageDialog Example')
        self.fixed.put(self.label, 80, 20)
        self.button = gtk.Button(u'关于')
        self.button.connect('clicked', self.OnButton, u'关于')
        self.fixed.put(self.button, 80, 150)

        self.button1 = gtk.Button('退出')
        self.button1.connect('clicked', self.OnButton1, u'退出')
        self.fixed.put(self.button1, 200, 150)
        self.window.add(self.fixed)
        self.label.show()
        self.button.show()
        self.button1.show()
        self.fixed.show()
        self.window.show()

    def OnButton(self, widget, data):
        msg = gtk.MessageDialog(self.window,
                                gtk.DIALOG_MODAL,
                                gtk.MESSAGE_INFO,
                                gtk.BUTTONS_OK,
                                '这只是一个例子')
        msg.run()
        msg.destroy()

    def OnButton1(self, widget, data):
        gtk.main_quit()

    def main(self):
        gtk.main()

if __name__ == '__main__':
    window = MyWindow('PyGTK', 300, 200)
    window.main()
